<?php

namespace Diablo7\HyperfPulsar\Message;

use Hyperf\Contract\PackerInterface;

abstract class ProducerMessage extends AbstractMessage implements ProducerMessageInterface
{
    public $payload;

    public function getSocketUri() :string
    {
        return sprintf("ws/v2/producer/persistent/%s/%s/%s", $this->getTenant(), $this->getNamespace(), $this->getTopic());
    }

    public function serialize() :string
    {
        $packer = $this->container->get(PackerInterface::class);
        return $packer->pack($this->payload);
    }
}